<template>
	<view class="discuss">
		<view class="homenavSelect" >
			<uniPicker title="请选择问题类型" ref="uniPicker" @p="pBtn"/>
		</view>
		<view class="mainblock">
			<view class="info">
				<view class="info-top">
					<textarea class="info-text" v-model="content" placeholder="想要什么样的功能?说不定就被满足了呢( @o◎)!万分欢迎功能吐槽，谁让你是我们最棒的用户呢。~"></textarea>
				</view>
			<view class="info-imgs">
				<shmily-drag-image boxpadding="15rpx" :cols="4"
					ref="dragImage" :number="9" :padding="5" :list.sync="imgArr" @updateList="updateList"
					/>
			</view>
			</view>
		</view>
		<view class="sub" @tap="sub()">
			提交反馈
		</view>
	</view>
</template>
<script>
	// 移动拖拽组件
	import shmilyDragImage from '@/components/shmily-drag-image/shmily-drag-image.vue'
	import uniPicker from '@/components/uni_picker/uni_picker.vue'
	export default {
		components: {
			shmilyDragImage,
			uniPicker
		},
		data() {
			return {
				content:'',
				// mobile:'',
				title:'',
				imgArr:[],
				id:'',
			}
		},
		onLoad(option) {
			if(option.id){
				this.id = option.id
			}
		},
		mounted() {
			this.id&&this.$refs['uniPicker'].changeShow({
				array:[
					{name:'【建议】功能吐槽或建议',id:'0'},
					{name:'【黄牛】举报入口 已处理283个牛',id:'1'},
					{name:'【购票、订单】问题',id:'2'},
					{name:'【换验票】问题',id:'3'},
					{name:'【显示、内容】错误',id:'4'},
					{name:'其他',id:'5'},
				],
				id:this.id
			})
		},
		methods: {
			updateList(e) {
				this.imgArr = e
			},
			pBtn(e){
				this.type = e.id
			},
			sub(){
				let that =this;
				if( this.id&&this.type == ''){
					uni.showToast({
						title:'请输入举报原因',
						icon:'none'
					});
					return;
				}
				if(this.content == ''){
					uni.showToast({
						title:'请输入反馈意见',
						icon:'none'
					});
					return;
				}
				var data = {
				   "moduls": this.id?"NEWS":"FEEDBACK",
				   "type":this.type,
				   "bizId":this.id,
					'title':this.title,
					'content':this.content,
					// 'phone':this.mobile,
					'imageList':this.imgArr.map((item)=>{
							return{
								'fileUrl':item,
								'fileName':item.slice(item.lastIndexOf('/')+1,item.lastIndexOf('.'))
							}
						})
				};
				this.$apiFun.postApi(this.$api.saveFeedbackApi,data,function(res){
					if(res.code == 200){
						uni.showToast({
							icon:'none',
							title:res.data,
						});
						setTimeout(() =>{
							uni.navigateBack()
						},2000);
					}
				},function(err){
					
				})
			},
		},
	} 
</script>
<style lang="scss">
	page{
		height: 100%;
		width: 100%;
		background: #f8f8f8;
		padding: 20rpx 30rpx 0;
		box-sizing: border-box;
		
	}
	.discuss{
		height: 100%;
		width: 100%;
		font-size: 30rpx;
		.homenavSelect{
			padding: 20rpx;
			box-sizing: border-box;
			display: flex;
			align-items: center;
			text-align: left;
			height:80rpx ;
			background: #ffffff;
			margin-bottom: 20rpx;
			.pickerBox{
				justify-content: space-between;
			}
			.homenavSelectImg{
				width:35rpx;
				height:30rpx;
				margin-left: 10rpx;
			}
		}
		.photo-class{
			margin-top:20rpx;
		}
		.info{
			background: #fff;
			width: 100%;
			margin: 0 auto;
			border-radius: 6rpx;
			.info-top{
				height: 160px;
				display: flex;
				padding: 10px;
				.info-name{
					width: 80px;
					margin-right: 10px;
					color: #666666;
				}
				.info-text{
					font-size: 28rpx;
					flex: 1;
					border: none;
					height: 100%;
				}
			}
			.info-imgs{
				padding: 10px;
				
			}
		}
		.place{
			width: 100%;
			margin: 40rpx auto;
			height: 96rpx;
			line-height: 96rpx;
			// padding:0 20rpx;
			background: #fff;
			border-radius:6rpx;
			display: flex;
		}
		.place-text{
			font-size: 28rpx;
			width: 100%;
			height: 100%;
			padding-left: 20rpx;
			box-sizing: border-box;
		}
		.sub{
			width: 100%;
			height: 80rpx;
			line-height: 80rpx;;
			background: red;
			color: #fff;
			text-align: center;
			position: fixed;
			left: 0;
			bottom: 0;
			border-radius: 6rpx;
			font-size: 32rpx;
		}
	}
</style>
